package com.example.web.filter;

import com.example.web.filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author 12071
 * @date 2022/7/29 15:49
 */
@Configuration
public class MyFilterConfig {
    @Bean
    public FilterRegistrationBean myFilterReg(){
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        MyFilter myfilter = new MyFilter();

        filterRegistrationBean.setFilter(myfilter);
        List<String> urls = new ArrayList<>();
        // 匹配所有路径
        urls.add("/*");

        filterRegistrationBean.setUrlPatterns(urls);

        return filterRegistrationBean;
    }
}
